<?php namespace App\Infra\Admin;

use App\Models\Article;
use App\Utils\ModelSDK\ModelOperator;

class ArticleManage{

	use ModelOperator;

	public function getArticles($conditions = ""){
		return $this->findModel(Article::class,Article::query()->orderBy('created_at','DESC'),$conditions,$first = true);
	}

	public function getArticle($id){
		return Article::find($id);
	}

	public function createArticle($data){
		$this->create(Article::class,$data);
	}

	public function updateArticle($id,$data){
		$this->update(Article::class,$id,$data);
	}

	public function deleteArticle($id){
		$article = Article::find($id);

		$article->delete();

		return $article;
	}
}